package com.ibenew.demo.bcspaneldemo.weight;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.support.v7.widget.AppCompatTextView;

/**
 * Created by HJJ on 2017/7/26.
 */

public class BorderTextView extends AppCompatTextView {
    public BorderTextView(Context context) {
        super(context);
    }
    @Override
    protected void onDraw(Canvas canvas)
    {
        super.onDraw(canvas);
        Paint paint = new Paint();

        // 将边框设为黑色.
        paint.setColor(android.graphics.Color.RED);

        // 画TextView的4个边.
        canvas.drawLine(0, 0, this.getWidth() - 1, 1, paint);
        canvas.drawLine(0, 0, 1, this.getHeight() - 1, paint);
        canvas.drawLine(this.getWidth() - 1, 0, this.getWidth() - 1, this.getHeight() - 1, paint);
        canvas.drawLine(0, this.getHeight() - 1, this.getWidth() - 1, this.getHeight() - 1, paint);
    }

}
